package com.hdax.dm.mappers;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hdax.dm.entity.item.DmItem;
import com.hdax.dm.entity.item.DmItemType;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ItemMapper extends BaseMapper<DmItem> {

    /*动态sql
    * <script>
    *   select * form dm_item
    *   <where>
            ...
        </where>
    * </script>
    * */

    //二级商品
    @Select(value = {
            "select * from dm_item",
            "where itemType1Id=#{itemType1Id} and isBanner=#{isBanner}",
            "order by startTime desc",
            "limit 5"
    })
    List<DmItem> items(@Param("itemType1Id") Long itemType1Id,@Param("isBanner") Long isBanner);


    //楼层
    @Select(value = {
            "SELECT * FROM `dm_item`",
                    "WHERE itemType1Id=#{itemType1Id}" ,
                    "ORDER BY id" ,
                    "LIMIT 5"
    })
    List<DmItem> floorItems(@Param("itemType1Id")Long itemType1Id);

    @Select(value = {
            "SELECT id,itemType FROM dm_item_type where parent=0"
    })
    List<DmItemType> floorData();

}
